home *** CD-ROM | disk | FTP | other *** search
- Path: xanth!cs.odu.edu!Amiga-Request
- From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
- Newsgroups: comp.sources.amiga
- Subject: v90i068: Snap 1.4 - cut, store, and paste between windows, Part02/04
- Message-ID: <11376@xanth.cs.odu.edu>
- Date: 11 Feb 90 22:50:04 GMT
- Sender: tadguy@cs.odu.edu
- Reply-To: micke@slaka.sirius.se (Mikael Karlsson)
- Lines: 1766
- Approved: tadguy@cs.odu.edu (Tad Guy)
- X-Mail-Submissions-To: Amiga@cs.odu.edu
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: micke@slaka.sirius.se (Mikael Karlsson)
- Posting-number: Volume 90, Issue 068
- Archive-name: util/snap-1.4/part02
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 4)."
- # Contents: source/ikm.c source/settings.c source/windows.c
- # startsnap.rexx
- # Wrapped by tadguy@xanth on Sun Feb 11 17:48:45 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'source/ikm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/ikm.c'\"
- else
- echo shar: Extracting \"'source/ikm.c'\" \(9076 characters\)
- sed "s/^X//" >'source/ikm.c' <<'END_OF_FILE'
- X/* ikm.c -- invert keymaps */
- X
- X/** NOTICE:
- X * The contents of this file are copyright 1987, Jim Mackraz. All rights
- X * reserved. No use of the contents of this file or the compilation
- X * of them may be used apart from the entire Commodities Exchange
- X * without written permission.
- X */
- X
- X#define CONTROLBITS ( (1 << 5) | (1 << 6) )
- X
- X/* return >= 0 if ok (no error checking now) */
- XULONG InvertKeyMap(ansicode, ie, km)
- XULONG ansicode;
- Xregister struct InputEvent *ie;
- Xstruct KeyMap *km;
- X{
- X ULONG kindex;
- X UBYTE code = 0;
- X extern struct KeyMap keymap;
- X
- X if (km == NULL) {
- X km = &keymap;
- X }
- X
- X ie->ie_Class = IECLASS_RAWKEY;
- X ie->ie_EventAddress = 0;
- X
- X /* check for codes in (default) high map first */
- X switch(ansicode)
- X {
- X case ' ':
- X code = 0x40; /* space */
- X break;
- X case 0x08: /* backspace */
- X code = 0x41;
- X break;
- X case '\t': /* tab */
- X code = 0x42;
- X break;
- X case 0x0D: /* return */
- X code = 0x44;
- X break;
- X case 0x1B: /* esc */
- X code = 0x45;
- X break;
- X case 0x7F: /* del */
- X code = 0x46;
- X break;
- X }
- X
- X if (code) {
- X ie->ie_Code = code;
- X ie->ie_Qualifier = 0;
- X return (1);
- X }
- X
- X if (LowKeyInvert((UBYTE) ansicode, km,
- X &ie->ie_Code, &ie->ie_Qualifier, &kindex) >= 0) {
- X if (kindex) { /* was dead key, need "preceding" keystroke. */
- X IndexKey(kindex, km, (ULONG *)&ie->ie_EventAddress);
- X }
- X }
- X
- X return (1);
- X}
- X
- X#define KEYMAPSIZE 64
- X
- X/* LowKeyInvert returns good code else <0 if no find
- X *
- X * regarding keymap as many-to-one mapping:
- X * -entries for a given key are scanned so that
- X * the minimum number of qualifiers are associated
- X * with the keystroke.
- X * -passing a character value of zero corresponds, in
- X * the default keymap, to CTRL-`, which is probably a bug.
- X * -numerals are matched with numeric pad keystrokes (no
- X * qualifiers) on standard keymap. The way to specify
- X * a key on the number row is via its shifted value;
- X * specify explicitly that the qualifier is to be unshifted,
- X * or a "don't care."
- X */
- XUWORD LowKeyInvert(value, km, codep, qualp, indexp)
- Xregister UBYTE value; /* translation value from low keymap */
- Xstruct KeyMap *km;
- XUWORD *codep; /* pointers where answers are to be put */
- XUWORD *qualp;
- XULONG *indexp; /* dead-key index information (put into ie?) */
- X{
- X register UWORD code = 0;
- X register WORD type;
- X register LONG *p; /* points to four-byte lokeymap entry */
- X WORD found_it = 0;
- X
- X *indexp = *qualp = 0;
- X
- X p = (LONG *) km->km_LoKeyMap;
- X
- X do {
- X /* determine type of key */
- X if ((type = km->km_LoKeyMapTypes[code] ) == KC_VANILLA) {
- X found_it = checkVanilla((UBYTE *)p, value, qualp);
- X } else if (type & KCF_DEAD) {
- X found_it = checkDead((UBYTE **)p, value, qualp, indexp);
- X }
- X /**
- X else if (type & KCF_STRING) {
- X }
- X **/
- X else if (!(type & KCF_NOP)) {
- X found_it = checkNormal((LONG)p, value, (UWORD)type, qualp);
- X }
- X
- X ++p;
- X } while (!found_it && ++code < KEYMAPSIZE);
- X
- X *codep = code;
- X return (code);
- X}
- X
- X/*
- X * packs code|qual of previous key (should be keys) in *dead_vudup
- X * returns code, <0 if failure
- X */
- XVOID IndexKey(inx, km, dead_vudup)
- XULONG inx;
- Xstruct KeyMap *km;
- XULONG *dead_vudup;
- X{
- X /* find keystroke which generates index */
- X
- X register WORD code = 0;
- X UWORD **p; /* points to four-byte lokeymap entry */
- X register UWORD *deadthing;
- X WORD i;
- X WORD qual = 0;
- X LONG vudu;
- X
- X p = (UWORD **) km->km_LoKeyMap;
- X
- X do {
- X /* check each deadkey in the table */
- X
- X if (km->km_LoKeyMapTypes[code] & KCF_DEAD) {
- X /* keymap entry is pointer to eight prefix:byte pairs */
- X
- X deadthing = *p;
- X for (i = 0; i < 8; ++i, ++deadthing) {
- X /* check for index prefix and correct index */
- X if (*deadthing == ((DPF_DEAD << 8) | inx)) {
- X deadQual((WORD)i, &qual);
- X goto FOUND_IT;
- X }
- X }
- X }
- X ++p;
- X } while (++code < KEYMAPSIZE);
- X
- XFOUND_IT:
- X
- X /* pack as follows: [pred(-1)|qual(-1)|pred(-2)|qual(-2)] */
- X /* for now, 2nd previous deadkey ignored */
- X
- X if (code < 0) {
- X *dead_vudup = 0;
- X } else {
- X vudu = code << 8;
- X vudu |= (0xFF & qual);
- X vudu <<= 16;
- X
- X *dead_vudup = vudu;
- X }
- X}
- X
- X
- XWORD checkNormal(four_bytesp, val, type, qualp)
- XLONG four_bytesp;
- XUBYTE val;
- XUWORD type;
- XUWORD *qualp;
- X{
- X register UBYTE *p = (UBYTE *) four_bytesp; /* codes held in long word */
- X register WORD position;
- X
- X /* start with last of four bytes, "more vanilla" */
- X p += 3;
- X
- X for (position = 3; position >= 0; --position, --p) {
- X if (*p == val) {
- X switch (type) {
- X case KC_NOQUAL:
- X if (position != 3) goto NOT_THIS;
- X break;
- X
- X case KCF_SHIFT:
- X if (!(position & 2)) goto NOT_THIS;
- X if (position == 2) *qualp |= IEQUALIFIER_LSHIFT;
- X break;
- X
- X case KCF_ALT:
- X if (!(position & 2)) goto NOT_THIS;
- X if (position == 2) *qualp |= IEQUALIFIER_LALT;
- X break;
- X
- X case KCF_CONTROL:
- X if (!(position & 2)) goto NOT_THIS;
- X if (position == 2) *qualp |= IEQUALIFIER_CONTROL;
- X break;
- X
- X case KCF_ALT | KCF_CONTROL:
- X if (!(position & 1)) *qualp |= IEQUALIFIER_LALT;
- X if (!(position & 2)) *qualp |= IEQUALIFIER_CONTROL;
- X break;
- X
- X case KCF_SHIFT | KCF_CONTROL:
- X if (!(position & 1)) *qualp |= IEQUALIFIER_LSHIFT;
- X if (!(position & 2)) *qualp |= IEQUALIFIER_CONTROL;
- X break;
- X
- X case KCF_SHIFT | KCF_ALT:
- X if (!(position & 1)) *qualp |= IEQUALIFIER_LSHIFT;
- X if (!(position & 2)) *qualp |= IEQUALIFIER_LALT;
- X break;
- X default:
- X break;
- X }
- X return (1);
- X }
- XNOT_THIS: ;
- X }
- X return (0);
- X}
- X
- XWORD checkVanilla(p, val, qualp)
- XUBYTE *p; /* note: byte pointer */
- XUBYTE val;
- XUWORD *qualp;
- X{
- X register WORD i;
- X
- X /* only one way to match a vanilla control key */
- X if (!(val & CONTROLBITS)) {
- X /* is a control code */
- X
- X if ((p[3] & ~CONTROLBITS) == val) {
- X *qualp |= IEQUALIFIER_CONTROL;
- X return (1);
- X }
- X } else {
- X /* not a control */
- X for (i = 3; i >= 0; --i) {
- X if (p[i] == val) {
- X if (!(i & 1)) *qualp |= IEQUALIFIER_LSHIFT;
- X if (!(i & 2)) *qualp |= IEQUALIFIER_LALT;
- X return (1);
- X }
- X }
- X }
- X return (0);
- X}
- X
- X
- XWORD checkDead(keybase, val, qualp, indexp)
- XUBYTE **keybase; /* note: byte pointer */
- XUBYTE val;
- XUWORD *qualp;
- XULONG *indexp;
- X{
- X WORD i;
- X WORD j;
- X
- X register UWORD *p = (UWORD *) *keybase;
- X /* need to remember keybase for offsets */
- X
- X UBYTE *deadp;
- X WORD found_it = 0;
- X
- X /* walk through eight two-byte entries, one for each qual. combo. */
- X for (i = 0; i < 8; ++i, ++p) {
- X switch (*p >> 8) {
- X case DPF_DEAD: /* dead keys do not themselves map to anything */
- X break;
- X case DPF_MOD: /* dead key modifiable */
- X deadp = *keybase + (*p & 0xFF);
- X /* look down the string indexed by dead-key index */
- X for (j = 0; j < 6; ++j) {
- X if (deadp[j] == val) {
- X found_it = 1;
- X *indexp = j;
- X break;
- X }
- X }
- X break;
- X case 0: /* normal stroke for this key */
- X if ((*p & 0xFF) == val) {
- X found_it = 1;
- X }
- X }
- X
- X if (found_it) {
- X deadQual((WORD)i, qualp);
- X return (1);
- X }
- X }
- X
- X return (0);
- X}
- X
- X/* figure out qualifier from position */
- XWORD deadQual(wordpos, qualp)
- XWORD wordpos; /* which word in dead-key string? */
- XUWORD *qualp;
- X{
- X if (wordpos & 1) *qualp |= IEQUALIFIER_LSHIFT;
- X if (wordpos & 2) *qualp |= IEQUALIFIER_LALT;
- X if (wordpos & 4) *qualp |= IEQUALIFIER_CONTROL;
- X return (0);
- X}
- X
- X
- END_OF_FILE
- if test 9076 -ne `wc -c <'source/ikm.c'`; then
- echo shar: \"'source/ikm.c'\" unpacked with wrong size!
- fi
- # end of 'source/ikm.c'
- fi
- if test -f 'source/settings.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/settings.c'\"
- else
- echo shar: Extracting \"'source/settings.c'\" \(12211 characters\)
- sed "s/^X//" >'source/settings.c' <<'END_OF_FILE'
- X#include "snap.h"
- X#include <stdio.h>
- X
- X#define ARGVAL() (*++(*argv) || (--argc && *++argv))
- X
- Xstruct SnapRsrc *SnapRsrc = NULL;
- X
- XSHORT isdigit(c)
- XREGISTER char c;
- X{
- X return (c>='0' && c<='9');
- X}
- X
- X#ifdef AZTEC_C
- Xchar *strupr(str)
- Xchar *str;
- X{
- X register char *p = str;
- X register char c;
- X while (c = *p) {
- X if ('a' <= c && c <= 'z') {
- X *p = c - ('a' - 'A');
- X }
- X ++p;
- X }
- X return str;
- X}
- X#endif AZTEC_C
- X
- XLONG dectoint(str)
- XREGISTER char *str;
- X{
- X REGISTER long val = 0;
- X REGISTER char c;
- X while (isdigit(c = *str)) {
- X val = (((val<<2)+val)<<1) + c-'0';
- X str++;
- X }
- X return(val);
- X}
- X
- XLONG hextoint(str)
- XREGISTER char *str;
- X{
- X REGISTER long val = 0;
- X REGISTER char c;
- X while (c = *str) {
- X val <<= 4;
- X val |= (c & 15) + (isdigit(c) ? 0 : 9);
- X str++;
- X }
- X return(val);
- X}
- X
- Xmain(argc, argv)
- XWORD argc;
- Xchar *argv[];
- X{
- X WORD usage = 0;
- X
- X SnapRsrc = (struct SnapRsrc *)OpenResource(SNAPRSRC);
- X if (!SnapRsrc) {
- X puts("Snap not installed");
- X exit(0);
- X }
- X
- X if (argc == 1) {
- X puts("Snap settings:");
- X printf("Priority: %d\n", SnapRsrc->Priority);
- X printf("Gfx Qual: %x, ", SnapRsrc->gfxqual);
- X printf("Text Qual: %x\n", SnapRsrc->textqual);
- X printf("Insert key: %x, ", SnapRsrc->insertkey);
- X printf("CW key: %x\n", SnapRsrc->cwkey);
- X printf("Prepend: \"%s\"\n", &SnapRsrc->Prepend);
- X printf("Append: \"%s\"\n", &SnapRsrc->Append);
- X printf("Xerox: %s, ", (SnapRsrc->flags & XEROX ? "On " : "Off"));
- X printf("Early patch: %s\n", (SnapRsrc->flags & EARLYPATCH ? "On " : "Off"));
- X printf("Join long: %s, ", (SnapRsrc->flags & JOINLONG ? "On " : "Off"));
- X printf("Underscore: %s\n", (SnapRsrc->flags & TRUEUNDERSCORE ? "True" : "Fake"));
- X printf("Line Delay: %ld, ", SnapRsrc->linedelay);
- X printf("Char Delay: %ld\n", SnapRsrc->chardelay);
- X printf("Crawl Ptrn: %x\n", SnapRsrc->CrawlPtrn);
- X printf("Start Unit: %d\n", SnapRsrc->StartUnit);
- X printf("Frame Mask: %x\n", SnapRsrc->FrameMask);
- X printf("Gad Offset: %d\n", SnapRsrc->GadOffset);
- X printf("Cache Size: %d\n", SnapRsrc->CacheSize);
- X printf("Bad char: %d\n", SnapRsrc->BadChar);
- X exit(0);
- X }
- X
- X for (argc--, argv++; argc > 0; argc--, argv++) {
- X if (**argv == '-') { /* Argument coming up */
- X switch(*++(*argv)) {
- X case 'p': priority: { /* Priority */
- X if (ARGVAL()) {
- X WORD pri = dectoint(*argv);
- X if (pri>50 && pri<128) {
- X SnapRsrc->Priority = pri;
- X }
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 't': textqual: {
- X if (ARGVAL()) {
- X SnapRsrc->textqual = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'g': gfxqual: {
- X if (ARGVAL()) {
- X SnapRsrc->gfxqual = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'i': insertkey: {
- X if (ARGVAL()) {
- X SnapRsrc->insertkey = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'w': cwkey: {
- X if (ARGVAL()) {
- X SnapRsrc->cwkey = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'c': chardelay: {
- X if (ARGVAL()) {
- X SnapRsrc->chardelay = dectoint(*argv) * 1000;
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'l': linedelay: {
- X if (ARGVAL()) {
- X SnapRsrc->linedelay = dectoint(*argv) * 1000;
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'a': crawlptrn: {
- X if (ARGVAL()) {
- X SnapRsrc->CrawlPtrn = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'X': noxerox: {
- X SnapRsrc->flags &= ~XEROX;
- X break;
- X }
- X case 'x': xerox: {
- X SnapRsrc->flags |= XEROX;
- X break;
- X }
- X case 'E': noearlypatch: {
- X SnapRsrc->flags &= ~EARLYPATCH;
- X break;
- X }
- X case 'e': earlypatch: {
- X SnapRsrc->flags |= EARLYPATCH;
- X break;
- X }
- X case 'R': fakeunderscore: {
- X SnapRsrc->flags &= ~TRUEUNDERSCORE;
- X break;
- X }
- X case 'r': realunderscore: {
- X SnapRsrc->flags |= TRUEUNDERSCORE;
- X break;
- X }
- X case 'J': nojoinlong: {
- X SnapRsrc->flags &= ~JOINLONG;
- X break;
- X }
- X case 'j': joinlong: {
- X SnapRsrc->flags |= JOINLONG;
- X break;
- X }
- X case 'A': append:
- X case 'P': prepend: {
- X char *dest = (**argv == 'A' ?
- X &SnapRsrc->Append[0] : &SnapRsrc->Prepend[0]);
- X if (*++(*argv) || (--argc && ++argv)) { /* "" is ok */
- X char *src = *argv;
- X WORD i = 16;
- X while (*src && i--) {
- X *dest++ = *src++;
- X }
- X *dest = '\0';
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'u': startunit: {
- X if (ARGVAL()) {
- X switch(dectoint(*argv)) {
- X case 1: {
- X SnapRsrc->StartUnit = UNIT_CHAR;
- X break;
- X }
- X case 0:
- X default: {
- X SnapRsrc->StartUnit = UNIT_FRAME;
- X break;
- X }
- X }
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'b': planemask: {
- X if (ARGVAL()) {
- X SnapRsrc->FrameMask = hextoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'o': gadoffset: {
- X if (ARGVAL()) {
- X SnapRsrc->GadOffset = dectoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'C': cachesize: {
- X if (ARGVAL()) {
- X SnapRsrc->CacheSize = dectoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'B': badchar: {
- X if (ARGVAL()) {
- X SnapRsrc->BadChar = dectoint(*argv);
- X } else {
- X usage = 1;
- X }
- X break;
- X }
- X case 'Q': quit: {
- X Signal(SnapRsrc->Task, SIGBREAKF_CTRL_C);
- X exit(0);
- X }
- X case '?': {
- X usage = 1;
- X break;
- X }
- X default: {
- X printf("Bad option: -%c.\n", **argv);
- X usage = 1;
- X break;
- X }
- X }
- X } else {
- X (VOID)strupr(*argv);
- X if (!strcmp(*argv, "PRIORITY")) {
- X (*argv)[1] = '\0'; /* Fake no argument */
- X goto priority; /* Terrible, ain't it? */
- X } else if (!strcmp(*argv, "TEXTQUAL")) {
- X (*argv)[1] = '\0';
- X goto textqual;
- X } else if (!strcmp(*argv, "GFXQUAL")) {
- X (*argv)[1] = '\0';
- X goto gfxqual;
- X } else if (!strcmp(*argv, "INSERTKEY")) {
- X (*argv)[1] = '\0';
- X goto insertkey;
- X } else if (!strcmp(*argv, "CWKEY")) {
- X (*argv)[1] = '\0';
- X goto cwkey;
- X } else if (!strcmp(*argv, "PREPEND")) {
- X (*argv)[1] = '\0';
- X goto prepend;
- X } else if (!strcmp(*argv, "APPEND")) {
- X (*argv)[1] = '\0';
- X goto append;
- X } else if (!strcmp(*argv, "CHARDELAY")) {
- X (*argv)[1] = '\0';
- X goto chardelay;
- X } else if (!strcmp(*argv, "LINEDELAY")) {
- X (*argv)[1] = '\0';
- X goto linedelay;
- X } else if (!strcmp(*argv, "CRAWLPTRN")) {
- X (*argv)[1] = '\0';
- X goto crawlptrn;
- X } else if (!strcmp(*argv, "XEROX")) {
- X goto xerox;
- X } else if (!strcmp(*argv, "NOXEROX")) {
- X goto noxerox;
- X } else if (!strcmp(*argv, "EARLYPATCH")) {
- X goto earlypatch;
- X } else if (!strcmp(*argv, "NOEARLYPATCH")) {
- X goto noearlypatch;
- X } else if (!strcmp(*argv, "TRUEUNDERSCORE")) {
- X goto realunderscore;
- X } else if (!strcmp(*argv, "FAKEUNDERSCORE")) {
- X goto fakeunderscore;
- X } else if (!strcmp(*argv, "JOINLONG")) {
- X goto joinlong;
- X } else if (!strcmp(*argv, "NOJOINLONG")) {
- X goto nojoinlong;
- X } else if (!strcmp(*argv, "STARTUNIT")) {
- X (*argv)[1] = '\0';
- X goto startunit;
- X } else if (!strcmp(*argv, "PLANEMASK")) {
- X (*argv)[1] = '\0';
- X goto planemask;
- X } else if (!strcmp(*argv, "GADOFFSET")) {
- X (*argv)[1] = '\0';
- X goto gadoffset;
- X } else if (!strcmp(*argv, "CACHESIZE")) {
- X (*argv)[1] = '\0';
- X goto cachesize;
- X } else if (!strcmp(*argv, "BADCHAR")) {
- X (*argv)[1] = '\0';
- X goto badchar;
- X } else if (!strcmp(*argv, "QUIT")) {
- X goto quit;
- X } else if (strcmp(*argv, "?")) {
- X printf("Bad switch/keyword: %s.\n", *argv);
- X }
- X usage = 1;
- X }
- X }
- X
- X if (usage) {
- X puts("Usage:");
- X puts(" snap -pNN -tXX -gXX -iXX -wXX -Pstr -Astr -cNN -lNN -aXXXX");
- X puts(" -x -X -e -E -r -R -j -J -uN -bXX -oNN -CNN -BNN -Q");
- X puts(" or");
- X puts(" snap PRIORITY/k TEXTQUAL/k GFXQUAL/k INSERTKEY/k CWKEY/k");
- X puts(" PREPEND/k APPEND/k CHARDELAY/k LINEDELAY/k CRAWLPTRN/k");
- X puts(" XEROX/s NOXEROX/s EARLYPATCH/s NOEARLYPATCH/s STARTUNIT/k");
- X puts(" TRUEUNDERSCORE/s FAKEUNDERSCORE/s JOINLONG/s NOJOINLONG/s");
- X puts(" PLANEMASK/k GADOFFSET/k CACHESIZE/k BADCHAR/s QUIT/s");
- X }
- X
- X /* Tell him there are new settings available */
- X Signal(SnapRsrc->Task, SIGBREAKF_CTRL_F);
- X}
- END_OF_FILE
- if test 12211 -ne `wc -c <'source/settings.c'`; then
- echo shar: \"'source/settings.c'\" unpacked with wrong size!
- fi
- # end of 'source/settings.c'
- fi
- if test -f 'source/windows.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'source/windows.c'\"
- else
- echo shar: Extracting \"'source/windows.c'\" \(10836 characters\)
- sed "s/^X//" >'source/windows.c' <<'END_OF_FILE'
- X/* Auto: make
- X*/
- X
- XIMPORT struct ArpBase *ArpBase;
- X
- Xstruct Window *ControlWindow = NULL;
- XIMPORT struct MsgPort *Sharedport;
- XIMPORT WORD Sharedrefs;
- X
- XIMPORT LONG TitleBarHeight;
- XIMPORT LONG ContentsFontHeight;
- XIMPORT struct RastPort MyRP;
- X
- X#define IDCMPFLAGS (MOUSEMOVE|NEWSIZE|CLOSEWINDOW|GADGETUP|ACTIVEWINDOW|INACTIVEWINDOW|MOUSEBUTTONS)
- X
- XUBYTE *WindowTitle = (UBYTE *)"Snap (c) 1989 Mikael Karlsson";
- X
- Xstruct Image DiskImage = {
- X 0, -1,
- X 16, 8, 1,
- X NULL,
- X 0x01, 0x00,
- X NULL
- X};
- X
- Xstruct Gadget DiskGad = {
- X NULL,
- X 0, 1,
- X 16, 8,
- X GADGIMAGE|GADGHCOMP|GRELRIGHT,
- X RELVERIFY,
- X BOOLGADGET,
- X (APTR)&DiskImage,
- X NULL,
- X NULL,
- X 0L,
- X NULL,
- X DISKGAD,
- X NULL,
- X};
- X
- Xstruct Gadget VProp = {
- X NULL,
- X -15, 10,
- X 16, -10,
- X GADGHCOMP|GRELRIGHT|GRELHEIGHT,
- X GADGIMMEDIATE|FOLLOWMOUSE|RELVERIFY,
- X PROPGADGET,
- X NULL,
- X NULL,
- X NULL,
- X 0L,
- X NULL,
- X VPROP,
- X NULL
- X};
- X
- Xstruct Gadget HProp = {
- X NULL,
- X 1, -8,
- X -15, 9,
- X GADGHCOMP|GRELBOTTOM|GRELWIDTH,
- X GADGIMMEDIATE|FOLLOWMOUSE|RELVERIFY,
- X PROPGADGET,
- X NULL,
- X NULL,
- X NULL,
- X 0L,
- X NULL,
- X HPROP,
- X NULL
- X};
- X
- Xstruct PropInfo VInfo = {
- X AUTOKNOB|FREEVERT,
- X 0, 0,
- X MAXBODY, MAXBODY,
- X 0, 0, 0, 0, 0, 0
- X};
- X
- Xstruct PropInfo HInfo = {
- X AUTOKNOB|FREEHORIZ,
- X 0, 0,
- X MAXBODY, MAXBODY,
- X 0, 0, 0, 0, 0, 0
- X};
- X
- Xstruct Image VImage = {
- X 0, 0, 0, 0, 0, NULL, 0, 0, NULL
- X};
- Xstruct Image HImage = {
- X 0, 0, 0, 0, 0, NULL, 0, 0, NULL
- X};
- X
- X/* Window structure for snapped gfx */
- Xstruct NewWindow Nw = {
- X 0, 1, /* LeftEdge, TopEdge */
- X 0, 0, /* Width, Height */
- X -1, -1, /* DetailPen, BlockPen */
- X NULL, /* IDCMPFlags */
- X WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|WINDOWSIZING|SMART_REFRESH|NOCAREREFRESH|RMBTRAP,
- X NULL, NULL, /* FirstGadget, CheckMark */
- X NULL,
- X NULL, NULL, /* Screen, BitMap */
- X 32, 32, /* MinWidth, MinHeight */
- X 0, 0, /* MaxWidth, MaxHeight */
- X WBENCHSCREEN /* Type */
- X};
- X
- XSHORT Coords3[5][2] = {
- X { 0, 0},
- X { 74, 0},
- X { 74, 10},
- X { 0, 10},
- X { 0, 0}
- X};
- X
- XSHORT Coords2[5][2] = {
- X { 0, 0},
- X { 74, 0},
- X { 74, 10},
- X { 0, 10},
- X { 0, 0}
- X};
- X
- XSHORT Coords1[5][2] = {
- X { 0, 0},
- X { 34, 0},
- X { 34, 10},
- X { 0, 10},
- X { 0, 0}
- X};
- X
- Xstruct Border Border3 = {
- X 42, 0,
- X 1, 0,
- X JAM1,
- X 5,
- X (SHORT *)&Coords3,
- X NULL
- X};
- X
- Xstruct Border Border2 = {
- X 42, 0,
- X 1, 0,
- X JAM1,
- X 5,
- X (SHORT *)&Coords2,
- X &Border3
- X};
- X
- Xstruct Border Border1 = {
- X 4, 0,
- X 1, 0,
- X JAM1,
- X 5,
- X (SHORT *)&Coords1,
- X &Border2
- X};
- X
- XUBYTE TranspBuf[5];
- X
- Xstruct StringInfo TranspSI = {
- X TranspBuf, /* Buf */
- X NULL, /* UndoBuf */
- X 0, /* BufferPos */
- X 4, /* MaxChars */
- X 0, /* DispPos */
- X 0, /* UndoPos */
- X 0, /* NumChars */
- X 0, /* DispCount */
- X 0, 0, /* CLeft, CTop */
- X NULL, /* Layer */
- X 0L, /* LongInt */
- X NULL /* AltKeyMap */
- X};
- X
- Xstruct Gadget TranspGad = {
- X NULL,
- X 5, 16,
- X 32, 8,
- X LONGINT,
- X RELVERIFY,
- X STRGADGET,
- X NULL,
- X NULL,
- X NULL,
- X 0L,
- X (APTR)&TranspSI,
- X 0,
- X NULL,
- X};
- X
- XUBYTE SaveName[256] = "";
- XUBYTE SaveDirName[256] = "";
- X
- Xstruct StringInfo NameSI = {
- X SaveName, /* Buf */
- X NULL, /* UndoBuf */
- X 0, /* BufferPos */
- X 255, /* MaxChars */
- X 0, /* DispPos */
- X 0, /* UndoPos */
- X 0, /* NumChars */
- X 0, /* DispCount */
- X 0, 0, /* CLeft, CTop */
- X NULL, /* Layer */
- X 0L, /* LongInt */
- X NULL /* AltKeyMap */
- X};
- X
- Xstruct Gadget NameGad = {
- X &TranspGad,
- X 5, 16,
- X 32, 8,
- X NULL,
- X NULL,
- X NULL,
- X NULL,
- X NULL,
- X NULL,
- X 0L,
- X NULL,
- X NAMEGAD,
- X NULL,
- X};
- X
- Xstruct Gadget SaveGad = {
- X &NameGad,
- X 5, 16,
- X 32, 8,
- X GADGHCOMP,
- X RELVERIFY,
- X BOOLGADGET,
- X NULL,
- X NULL,
- X NULL,
- X 0L,
- X NULL,
- X SAVEGAD,
- X NULL,
- X};
- X
- X/* Window structure for control window */
- Xstruct NewWindow NewCW = {
- X 10, 10, /* LeftEdge, TopEdge */
- X 320, 40, /* Width, Height */
- X -1, -1, /* DetailPen, BlockPen */
- X NULL, /* IDCMPFlags */
- X WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|SMART_REFRESH|ACTIVATE|NOCAREREFRESH,
- X NULL, NULL, /* FirstGadget, CheckMark */
- X (UBYTE *)"Snap Control Window",
- X NULL, NULL, /* Screen, BitMap */
- X 32, 32, /* MinWidth, MinHeight */
- X -1, -1, /* MaxWidth, MaxHeight */
- X WBENCHSCREEN /* Type */
- X};
- X
- Xstruct FileRequester NameFR = {
- X "Save picture as...",
- X (BYTE *)SaveName,
- X (BYTE *)SaveDirName,
- X NULL,
- X NULL,
- X NULL,
- X NULL,
- X NULL
- X};
- X
- Xstruct Window *opensharedwindow(nw)
- Xstruct NewWindow *nw;
- X{
- X struct Window *win;
- X struct Screen scr;
- X
- X if (Sharedport) {
- X nw->IDCMPFlags = NULL;
- X } else {
- X nw->IDCMPFlags = IDCMPFLAGS;
- X }
- X if (!GetScreenData((char *)&scr, (LONG)sizeof(struct Screen),
- X WBENCHSCREEN, NULL)) {
- X return NULL; /* No WB */
- X }
- X if (nw->TopEdge+nw->Height > scr.Height) {
- X nw->TopEdge = scr.Height-nw->Height;
- X }
- X if (nw->LeftEdge+nw->Width > scr.Width) {
- X nw->LeftEdge = scr.Width-nw->Width;
- X }
- X if (nw->TopEdge < 0) {
- X nw->TopEdge = 0;
- X }
- X if (nw->LeftEdge < 0) {
- X nw->LeftEdge = 0;
- X }
- X if (nw->TopEdge+nw->Height > scr.Height) {
- X nw->Height = scr.Height-nw->TopEdge;
- X }
- X if (nw->LeftEdge+nw->Width > scr.Width) {
- X nw->Width = scr.Width-nw->LeftEdge;
- X }
- X
- X if (win = OpenWindow(nw)) {
- X if (Sharedport) {
- X win->UserPort = Sharedport;
- X ModifyIDCMP(win, IDCMPFLAGS);
- X } else {
- X Sharedport = win->UserPort;
- X }
- X ++Sharedrefs;
- X }
- X return(win);
- X}
- X
- X
- XVOID closesharedwindow(win)
- Xstruct Window *win;
- X{
- X Forbid();
- X Sharedrefs--;
- X if (Sharedrefs > 0) {
- X REGISTER struct IntuiMessage *im, *succ;
- X im = (struct IntuiMessage *)win->UserPort->mp_MsgList.lh_Head;
- X while (succ = (struct IntuiMessage *)im->ExecMessage.mn_Node.ln_Succ) {
- X if (im->IDCMPWindow == win) {
- X Remove(im);
- X ReplyMsg(im);
- X }
- X im = succ;
- X }
- X win->UserPort = NULL;
- X ModifyIDCMP(win, MENUVERIFY); /* NEVER occurs */
- X } else
- X Sharedport = NULL;
- X Permit();
- X CloseWindow(win);
- X}
- X
- XVOID SetUpBorder(Border, Gad)
- Xstruct Border *Border;
- Xstruct Gadget *Gad;
- X{
- X Border->LeftEdge = Gad->LeftEdge-1;
- X Border->TopEdge = Gad->TopEdge-1;
- X Border->XY[2] = Border->XY[4] = Gad->Width+1;
- X Border->XY[5] = Border->XY[7] = Gad->Height+1;
- X}
- X
- XVOID AdjustSize(GS)
- Xstruct GfxSnap *GS;
- X{
- X ULONG w = GS->window->Width - 18;
- X ULONG h = GS->window->Height - GS->VProp.TopEdge - 9;
- X ULONG vb, hb;
- X
- X vb = hb = MAXBODY;
- X
- X if (w < GS->width) {
- X hb = w * (ULONG)MAXBODY / GS->width;
- X }
- X if (h < GS->height) {
- X vb = h * (ULONG)MAXBODY / GS->height;
- X }
- X NewModifyProp(&GS->VProp, GS->window, NULL, (ULONG)AUTOKNOB|FREEVERT,
- X 0L, 0L, (ULONG)MAXBODY, vb, 1L);
- X NewModifyProp(&GS->HProp, GS->window, NULL, (ULONG)AUTOKNOB|FREEHORIZ,
- X 0L, 0L, hb, (ULONG)MAXBODY, 1L);
- X InitRastPort(&MyRP);
- X MyRP.BitMap = &GS->BM;
- X ClipBlit(&MyRP, 0L, 0L, GS->window->RPort,
- X 2L, (LONG)GS->VProp.TopEdge, w, h, 0xC0L);
- X}
- X
- XVOID SyncGS(GS)
- Xstruct GfxSnap *GS;
- X{
- X ULONG w = GS->window->Width - 18;
- X ULONG h = GS->window->Height - GS->VProp.TopEdge - 9;
- X ULONG vpos, hpos;
- X LONG temp;
- X
- X temp = GS->width - w;
- X if (temp <= 0) {
- X hpos = 0;
- X } else {
- X hpos = temp * (LONG)GS->HInfo.HorizPot / MAXBODY;
- X if (hpos > temp) {
- X hpos = temp;
- X }
- X }
- X temp = GS->height - h;
- X if (temp <= 0) {
- X vpos = 0;
- X } else {
- X vpos = temp * (LONG)GS->VInfo.VertPot / MAXBODY;
- X if (vpos > temp) {
- X vpos = temp;
- X }
- X }
- X InitRastPort(&MyRP);
- X MyRP.BitMap = &GS->BM;
- X ClipBlit(&MyRP, hpos, vpos, GS->window->RPort,
- X 2L, (LONG)GS->VProp.TopEdge, w, h, 0xC0L);
- X}
- X
- XSHORT OpenCW()
- X{
- X WORD temp;
- X
- X FixHeights();
- X
- X NewCW.Height = TitleBarHeight + ContentsFontHeight * 2 + 12;
- X ControlWindow = opensharedwindow(&NewCW);
- X if (!ControlWindow) {
- X return 0;
- X }
- X SaveGad.TopEdge = NameGad.TopEdge = TitleBarHeight + 2;
- X SaveGad.Height = NameGad.Height = TranspGad.Height = ContentsFontHeight+2;
- X TranspGad.TopEdge = SaveGad.TopEdge + SaveGad.Height + 3;
- X
- X SaveGad.LeftEdge = 4L;
- X SaveGad.Width = TextLength(ControlWindow->RPort, "Save", 4L) + 1;
- X if (Sharedrefs == 1) { /* No snap window, just control window? */
- X SaveGad.Flags |= GADGDISABLED;
- X } else {
- X SaveGad.Flags &= ~GADGDISABLED;
- X }
- X
- X NameGad.LeftEdge = SaveGad.LeftEdge +
- X TextLength(ControlWindow->RPort, "Save as ", 8L);
- X temp = ControlWindow->Width - 4 - NameGad.LeftEdge;
- X NameGad.Width =
- X temp - (temp % TextLength(ControlWindow->RPort, " ", 1L)) + 1;
- X
- X TranspGad.LeftEdge = SaveGad.LeftEdge +
- X TextLength(ControlWindow->RPort, "Transparent color ", 18L);
- X TranspGad.Width = TextLength(ControlWindow->RPort, "0000", 4L);
- X
- X SetUpBorder(&Border1, &SaveGad);
- X SetUpBorder(&Border2, &NameGad);
- X SetUpBorder(&Border3, &TranspGad);
- X
- X ++TranspGad.LeftEdge;
- X ++TranspGad.TopEdge;
- X
- X if (ArpBase) {
- X NameGad.Flags = GADGHCOMP;
- X NameGad.Activation = RELVERIFY;
- X NameGad.GadgetType = BOOLGADGET;
- X NameGad.SpecialInfo = NULL;
- X } else {
- X NameGad.Flags = SELECTED;
- X NameGad.Activation = NULL;
- X NameGad.GadgetType = STRGADGET;
- X NameGad.SpecialInfo = (APTR)&NameSI;
- X ++NameGad.LeftEdge; /* Adjust string gadget position */
- X ++NameGad.TopEdge; /* Adjust string gadget position */
- X }
- X
- X strcpy(SaveName, "Snap.pic");
- X strcpy(TranspBuf, "0");
- X TranspSI.LongInt = 0L;
- X
- X SetAPen(ControlWindow->RPort, 1L);
- X SetBPen(ControlWindow->RPort, 0L);
- X SetDrMd(ControlWindow->RPort, JAM2);
- X Move(ControlWindow->RPort,
- X 5L, (LONG)SaveGad.TopEdge + 1 + ControlWindow->RPort->Font->tf_Baseline);
- X Text(ControlWindow->RPort, "Save as", 7L);
- X Move(ControlWindow->RPort,
- X 5L, (LONG)TranspGad.TopEdge + ControlWindow->RPort->Font->tf_Baseline);
- X Text(ControlWindow->RPort, "Transparent color", 17L);
- X DrawBorder(ControlWindow->RPort, &Border1, 0L, 0L);
- X AddGList(ControlWindow, &SaveGad, -1L, 3L, NULL);
- X RefreshGList(&SaveGad, ControlWindow, NULL, 3L);
- X if (ArpBase) {
- X GadText(&NameGad, SaveName, 8L);
- X } else {
- X ActivateGadget(&NameGad, ControlWindow, NULL);
- X }
- X return 1;
- X}
- END_OF_FILE
- if test 10836 -ne `wc -c <'source/windows.c'`; then
- echo shar: \"'source/windows.c'\" unpacked with wrong size!
- fi
- # end of 'source/windows.c'
- fi
- if test -f 'startsnap.rexx' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'startsnap.rexx'\"
- else
- echo shar: Extracting \"'startsnap.rexx'\" \(13368 characters\)
- sed "s/^X//" >'startsnap.rexx' <<'END_OF_FILE'
- X/* Arexx script to help people with Snap arguments */
- X
- Xsignal on error
- X
- Xif ~show('l', "rexxarplib.library") then do
- X check = addlib('rexxsupport.library',0,-30,0)
- X check = addlib('rexxmathlib.library',0,-30,0)
- X check = addlib('rexxarplib.library',0,-30,0)
- Xend
- X
- Xif ~exists("fonts:helvetica/15") then do
- X say "Actually I need font 'Helvetica 15', but I'll try anyway."
- Xend
- X
- Xbool.0 = 'OFF'; bool.1 = 'ON'
- X
- X/* Fix window dimensions */
- X
- Xscreen.width = ScreenCols()
- Xscreen.height = ScreenRows()
- X
- Xwindow.width = 530
- Xwindow.height = 200
- Xwindow.leftedge = (screen.width-window.width)/2
- Xwindow.topedge = (screen.height-window.height)/2
- X
- X/* Set up a host */
- Xparse version 'V' vers .
- Xsignal on syntax
- Xcall stop(SNAPHOST)
- Xsyntax:
- Xif vers > 1.06 then
- X address AREXX "'call CreateHost(SNAPHOST, SNAPPORT)'"
- Xelse
- X "runwsh >nil:" "'call CreateHost(SNAPHOST, SNAPPORT)'"
- X
- X/*
- X* Wait for a while until host is ready.
- X*/
- Xdo for 50 while ~show('Ports','SNAPHOST')
- X call delay 10 /* 200 ms */
- Xend
- X
- Xcall SetReqColor(SNAPHOST, BLOCKPEN, 1)
- Xcall SetReqColor(SNAPHOST, DETAILPEN, 0)
- X
- X/*
- X* Open the window
- X*/
- Xwindow.idcmp = 'CLOSEWINDOW+GADGETUP+RAWKEY'
- Xwindow.flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
- X
- Xtitle = "Setup tool for Snap"
- X
- Xcall OpenWindow(SNAPHOST, window.leftedge, window.topedge, window.width, ,
- X window.height, window.idcmp, window.flags, title)
- X
- Xcall ModifyHost(SNAPHOST, RAWKEY, "RAWKEY %c")
- X
- Xif exists("fonts:Helvetica/15") then do
- X call SetFont(SNAPHOST, "Helvetica.font", 15)
- Xend
- X
- Xsignal dotext
- X/* --- Start of texts ---
- X" Please hold on..." 5 20 60 ""
- X"Priority:" 5 40 6 "Input handler priority."
- X"Insert key:" 215 60 9 "Key used with Left Amiga to insert."
- X"Window key:" 215 80 9 "Key used with Left Amiga to open control window."
- X"Char delay:" 215 100 9 "Delay after each inserted character"
- X"Line delay:" 215 120 9 "Delay after each inserted newline."
- X"Bit mask:" 215 140 9 "Bit planes to draw selection frame into."
- X"Starting unit:" 215 160 9 "Unit in which to start snapping."
- X"Prepend:" 5 180 6 "Characters added in front of each line in modified inserts."
- X"Append:" 215 180 6 "Characters added at the end of each line in modified inserts."
- X"Selection frame pattern:" 345 40 19 "Pattern used for crawling dots in selection frame."
- X"Text qualifier:" 5 60 11 "Qualifier used when snapping characters."
- X"Gfx qualifier:" 110 60 11 "Qualifier used when snapping graphics."
- XEOT
- X--- End of texts --- */
- X
- Xdotext:
- Xtextlines = sigl+1
- X
- Xcall SetReqColor(SNAPHOST, 'BOXPEN', 0)
- Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 0)
- Xcall SetAPen(SNAPHOST, 1)
- Xdo i=1 while sourceline(textlines+i) ~= "EOT"
- X parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
- X call AddGadget(SNAPHOST, x, y, 'HLP'i, copies(' ',w), "HELP "help)
- Xend
- X
- Xcall SetReqColor(SNAPHOST, 'BOXPEN', 2)
- Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 3)
- Xdo i=1 while sourceline(textlines+i) ~= "EOT"
- X parse value sourceline(textlines+i) with '"'text'"' x y w . '"'help'"'
- X call Move(SNAPHOST, x, y+10); call Text(SNAPHOST, text)
- Xend
- X
- X/* Set up some nice gadgets */
- Xx = 65
- Xdo i=51 for 5
- X call AddGadget(SNAPHOST, x, 40, 'PR'i, ''i'', 'PRIORITY 'i); x = x+27
- Xend
- X
- Xinscode.1 = 23; inscode.2 = 15; inscode.3 = 34
- Xinskey.1 = 'I'; inskey.2 = 'Y'; inskey.3 = 'V'
- Xx = 300
- Xdo i=1 for 3
- X call AddGadget(SNAPHOST, x, 60, 'INS'i, inskey.i, 'INSKEY 'i); x = x+20
- Xend
- X
- Xcwcode.1 = 17; cwcode.2 = 51; cwcode.3 = 24
- Xcwkey.1 = 'W'; cwkey.2 = 'C'; cwkey.3 = 'O'
- Xx = 300
- Xdo i=1 for 3
- X call AddGadget(SNAPHOST, x, 80, 'CW'i, cwkey.i, 'CWKEY 'i); x = x+20
- Xend
- X
- Xx = 300
- Xdo i=0 for 3
- X call AddGadget(SNAPHOST, x, 100, 'CDL'i, i, 'CDELAY 'i); x = x+20
- Xend
- X
- Xx = 300
- Xdo i=0 for 3
- X call AddGadget(SNAPHOST, x, 120, 'LDL'i, i, 'LDELAY 'i); x = x+20
- Xend
- X
- Xx = 300
- Xdo i=0 for 3
- X call AddGadget(SNAPHOST, x, 140, 'MSK'i, i, 'MASK 'i); x = x+20
- Xend
- X
- Xcall AddGadget(SNAPHOST, 300, 160, 'UNT'0, "Frame", 'UNIT 0')
- Xcall AddGadget(SNAPHOST, 350, 160, 'UNT'1, "Char ", 'UNIT 1')
- X
- Xcall AddGadget(SNAPHOST, 365, 60, 'XERX', 'Immediate insert', 'XEROX')
- Xcall AddGadget(SNAPHOST, 365, 80, 'JOIN', 'Join long lines ', 'JOIN')
- Xcall AddGadget(SNAPHOST, 365, 100, 'PTCH', 'Early patch ', 'PATCH')
- Xcall AddGadget(SNAPHOST, 365, 120, 'USCR', 'True underscore ', 'UNDERSCORE')
- X
- Xcall AddGadget(SNAPHOST, 70, 180, 'PREP', "> ", 'PREP %g', 128)
- Xcall AddGadget(SNAPHOST, 280, 180, 'APP', "", 'APP %g', 128)
- X
- Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 0L)
- Xy = 18
- Xdo i=0 for 16
- X call AddGadget(SNAPHOST, 510, y, 'PAT'i, ' ', 'PATTERN 'i); y = y+11
- Xend
- Xcall SetReqColor(SNAPHOST, 'SHADOWPEN', 3L)
- X
- Xbit.1 = 0; desc.1 = 'Left Shift '
- Xbit.2 = 1; desc.2 = 'Right Shift'
- Xbit.3 = 3; desc.3 = 'Control '
- Xbit.4 = 4; desc.4 = 'Left Alt '
- Xbit.5 = 5; desc.5 = 'Right Alt '
- Xbit.6 = 6; desc.6 = 'Left Amiga '
- Xbit.7 = 7; desc.7 = 'Right Amiga'
- X
- Xy = 75
- Xdo i=1 for 7
- X call AddGadget(SNAPHOST, 5, y, 'TQ'i, desc.i, 'TEXTQUAL 'i)
- X call AddGadget(SNAPHOST, 110, y, 'GQ'i, desc.i, 'GFXQUAL 'i)
- X y = y+15
- Xend
- X
- Xcall AddGadget(SNAPHOST, 430, 172, 'APPLY', ' Apply\settings', 'APPLY')
- X
- X/* Open our host port */
- Xcall openport(SNAPPORT)
- X
- Xstart:
- X
- Xcall ShowText(" Setting defaults...")
- Xpri = 51; call SetGadget(SNAPHOST, 'PR51', 'ON')
- Xtextqual = '0040'x; call SetGadget(SNAPHOST, 'TQ6', 'ON')
- Xgfxqual = '0080'x; call SetGadget(SNAPHOST, 'GQ7', 'ON')
- Xinskey = 1; call SetGadget(SNAPHOST, 'INS1', 'ON')
- Xcwkey = 1; call SetGadget(SNAPHOST, 'CW1', 'ON')
- Xcdelay = 0; call SetGadget(SNAPHOST, 'CDL0', 'ON')
- Xldelay = 0; call SetGadget(SNAPHOST, 'LDL0', 'ON')
- Xpattern = '7777'x;
- Xdo i=0 for 16
- X if bittst(pattern,i) then call SetGadget(SNAPHOST, 'PAT'i, 'ON')
- Xend
- Xunit = 0; call SetGadget(SNAPHOST, 'UNT0', 'ON')
- Xxerox = 0
- Xpatch = 0
- Xjoin = 0
- Xunderscore = 1; call SetGadget(SNAPHOST, 'USCR', 'ON')
- Xplanes = '00'x
- X
- Xcall ShowText(" Select options. Click here for help.")
- X
- Xhelp.1 = "Click text (eg 'Priority') for help. Click here for more help."
- Xhelp.2 = "Close window for correct command line. Click for more."
- Xhelp.3 = "Click 'Apply settings' to reconfigure Snap."
- Xmaxhelp = 3
- X
- Xkeycmd. = ""
- Xkeycmd.95 = "HELP"; keycmd.25 = "PRIORITY"; keycmd.16 = "CLOSEWINDOW"
- Xkeycmd.23 = "INSKEY"; keycmd.51 = "CDELAY"; keycmd.40 = "LDELAY"
- Xkeycmd.33 = "UNIT"; keycmd.32 = "APPLY"
- X
- Xmain:
- Xquitflag = 0
- Xhelpnum = 1
- X
- Xloop:
- Xif quitflag~=0 then signal done
- X
- Xcall waitpkt(SNAPPORT)
- Xp = getpkt(SNAPPORT)
- Xif p == NULL() then signal loop
- X
- Xcmd = getarg(p)
- Xcall reply(p, 0)
- X
- Xdocmd:
- Xparse var cmd item val .
- Xsignal value item
- X
- Xclosewindow:
- X quitflag = 1
- X signal loop
- X
- Xrawkey:
- X cmd = keycmd.val
- X if cmd ~= "" then do
- X signal docmd
- X end
- X signal loop
- X
- Xhelp:
- X parse var cmd item help
- X if help="" then do
- X call showtext(help.helpnum)
- X helpnum = helpnum+1
- X if helpnum>maxhelp then helpnum = 1
- X end
- X else do
- X call showtext(help)
- X end
- X signal loop
- X
- Xpriority:
- X if val="" then do
- X val = pri+1
- X if val>55 then val = 51
- X end
- X pri = val
- X do i=51 for 5
- X call setgadget(SNAPHOST, 'PR'i, 'OFF')
- X end
- X call setgadget(SNAPHOST, 'PR'pri, 'ON')
- X signal loop
- X
- Xinskey:
- X if val="" then do
- X val = inskey+1
- X if val>3 then val = 1
- X end
- X inskey = val
- X do i=1 for 3
- X call setgadget(SNAPHOST, 'INS'i, 'OFF')
- X end
- X call setgadget(SNAPHOST, 'INS'val, 'ON')
- X signal loop
- X
- Xcwkey:
- X if val="" then do
- X val = cwkey+1
- X if val>3 then val = 1
- X end
- X cwkey = val
- X do i=1 for 3
- X call setgadget(SNAPHOST, 'CW'i, 'OFF')
- X end
- X call setgadget(SNAPHOST, 'CW'val, 'ON')
- X signal loop
- X
- Xcdelay:
- X if val="" then do
- X val = cdelay+1
- X if val>2 then val = 0
- X end
- X cdelay = val
- X do i=0 for 3
- X call setgadget(SNAPHOST, 'CDL'i, 'OFF')
- X end
- X call setgadget(SNAPHOST, 'CDL'val, 'ON')
- X signal loop
- X
- Xldelay:
- X if val="" then do
- X val = ldelay+1
- X if val>2 then val = 0
- X end
- X ldelay = val
- X do i=0 for 3
- X call setgadget(SNAPHOST, 'LDL'i, 'OFF')
- X end
- X call setgadget(SNAPHOST, 'LDL'val, 'ON')
- X signal loop
- X
- Xunit:
- X if val="" then do
- X val = 1-unit
- X end
- X unit = val
- X call setgadget(SNAPHOST, 'UNT0', 'OFF')
- X call setgadget(SNAPHOST, 'UNT1', 'OFF')
- X call setgadget(SNAPHOST, 'UNT'unit, 'ON')
- X signal loop
- X
- Xpattern:
- X pattern = bitchg(pattern,val)
- X temp = bittst(pattern,val)
- X call setgadget(SNAPHOST, 'PAT'val, bool.temp)
- X signal loop
- X
- Xmask:
- X planes = bitchg(planes,val)
- X temp = bittst(planes,val)
- X call setgadget(SNAPHOST, 'MSK'val, bool.temp)
- X signal loop
- X
- Xprep:
- X parse var cmd . ' ' prepend
- X signal loop
- X
- Xapp:
- X parse var cmd . ' ' append
- X signal loop
- X
- Xtextqual:
- X if bittst(textqual,bit.val) then do
- X textqual = bitclr(textqual,bit.val)
- X call setgadget(SNAPHOST, 'TQ'val, 'OFF')
- X end
- X else do
- X call setgadget(SNAPHOST, 'GQ'val, 'OFF')
- X gfxqual = bitclr(gfxqual,bit.val)
- X textqual = bitset(textqual,bit.val)
- X call setgadget(SNAPHOST, 'TQ'val, 'ON')
- X end
- X signal loop
- X
- Xgfxqual:
- X if bittst(gfxqual,bit.val) then do
- X gfxqual = bitclr(gfxqual,bit.val)
- X call setgadget(SNAPHOST, 'GQ'val, 'OFF')
- X end
- X else do
- X call setgadget(SNAPHOST, 'TQ'val, 'OFF')
- X textqual = bitclr(textqual,bit.val)
- X gfxqual = bitset(gfxqual,bit.val)
- X call setgadget(SNAPHOST, 'GQ'val, 'ON')
- X end
- X signal loop
- X
- Xxerox:
- X xerox = 1-xerox
- X call setgadget(SNAPHOST, 'XERX', bool.xerox)
- X signal loop
- X
- Xjoin:
- X join = 1-join
- X call setgadget(SNAPHOST, 'JOIN', bool.join)
- X signal loop
- X
- Xpatch:
- X patch = 1-patch
- X call setgadget(SNAPHOST, 'PTCH', bool.patch)
- X signal loop
- X
- Xunderscore:
- X underscore = 1-underscore
- X call setgadget(SNAPHOST, 'USCR', bool.underscore)
- X signal loop
- X
- Xapply:
- X quitflag = 2
- X signal loop
- X
- X
- Xdone:
- Xcall ReadGadget(SNAPHOST, 'PREP')
- Xcall waitpkt(SNAPPORT)
- Xgetprep:
- Xp = getpkt(SNAPPORT)
- Xif p == NULL() then signal getprep
- X
- Xcmd = getarg(p)
- Xcall reply(p, 0)
- Xparse var cmd . ' ' prepend
- X
- Xcall ReadGadget(SNAPHOST, 'APP')
- Xcall waitpkt(SNAPPORT)
- Xgetapp:
- Xp = getpkt(SNAPPORT)
- Xif p == NULL() then signal getapp
- X
- Xcmd = getarg(p)
- Xcall reply(p, 0)
- Xparse var cmd . ' ' append
- X
- Xif c2d(textqual)=0 then do
- X call ShowText("No text qualifier specified!")
- X signal main
- Xend
- Xelse if c2d(gfxqual)=0 then do
- X call ShowText("No graphics qualifier specified!")
- X signal main
- Xend
- X
- Xunixargs = ""
- Xamigaargs = ""
- Xif pri~=51 then do
- X unixargs = unixargs "-p"pri
- X amigaargs = amigaargs "priority" pri
- Xend
- Xif textqual~='0040'x then do
- X unixargs = unixargs "-t"c2x(textqual)
- X amigaargs = amigaargs "textqual" c2x(textqual)
- Xend
- Xif gfxqual~='0080'x then do
- X unixargs = unixargs "-g"c2x(gfxqual)
- X amigaargs = amigaargs "gfxqual" c2x(gfxqual)
- Xend
- Xif inskey.inskey~='I' then do
- X unixargs = unixargs "-i"inscode.inskey
- X amigaargs = amigaargs "insertkey" inscode.inskey
- Xend
- Xif cwkey.cwkey~='W' then do
- X unixargs = unixargs "-w"cwcode.cwkey
- X amigaargs = amigaargs "cwkey" cwcode.cwkey
- Xend
- Xif prepend~="> " then do
- X unixargs = unixargs "-P" '"'||prepend||'"'
- X amigaargs = amigaargs "prepend" '"'||prepend||'"'
- Xend
- Xif append~="" then do
- X unixargs = unixargs "-A" '"'append'"'
- X amigaargs = amigaargs "append" '"'append'"'
- Xend
- Xif cdelay~=0 then do
- X unixargs = unixargs "-c"cdelay
- X amigaargs = amigaargs "chardelay" cdelay
- Xend
- Xif ldelay~=0 then do
- X unixargs = unixargs "-l"ldelay
- X amigaargs = amigaargs "linedelay" ldelay
- Xend
- Xif pattern~='7777'x then do
- X unixargs = unixargs "-a"c2x(pattern)
- X amigaargs = amigaargs "crawlptrn" c2x(pattern)
- Xend
- Xif xerox then do
- X unixargs = unixargs "-x"
- X amigaargs = amigaargs "XEROX"
- Xend
- Xif patch then do
- X unixargs = unixargs "-e"
- X amigaargs = amigaargs "EARLYPATCH"
- Xend
- Xif underscore then do
- X unixargs = unixargs "-r"
- X amigaargs = amigaargs "TRUEUNDERSCORE"
- Xend
- Xif join then do
- X unixargs = unixargs "-j"
- X amigaargs = amigaargs "JOINLONG"
- Xend
- Xif unit~=0 then do
- X unixargs = unixargs "-u"unit
- X amigaargs = amigaargs "startunit" unit
- Xend
- Xif planes~='00'x then do
- X unixargs = unixargs "-b"c2x(planes)
- X amigaargs = amigaargs "planemask" c2x(planes)
- Xend
- X
- Xsnapcmd = "snap"
- X
- Xif quitflag=1 then do
- X say snapcmd || unixargs
- X if amigaargs ~= unixargs then do
- X say "or"
- X say snapcmd || amigaargs
- X end
- Xend
- Xelse do
- X if ~exists("snap") & ~exists("c:snap") then do
- X snapcmd = GetFile(50, 50, "sys:", "", "Find Snap for me")
- X if word(statef(snapcmd),1) ~= 'FILE' then do
- X snapcmd = snapcmd'snap'
- X end
- X end
- X if exists(snapcmd) then do
- X address command snapcmd unixargs
- X end
- X else do
- X call ShowText("Snap not found.")
- X signal main
- X end
- Xend
- X
- Xerror:
- Xcall Stop(SNAPHOST)
- Xexit
- X
- Xshowtext: procedure expose SNAPHOST
- X
- Xparse arg text
- X
- Xcall SetAPen(SNAPHOST, 0)
- Xcall RectFill(SNAPHOST, 5, 15, 490, 35)
- Xcall SetAPen(SNAPHOST, 1)
- Xcall Move(SNAPHOST, 5, 30)
- Xcall Text(SNAPHOST, text)
- Xreturn
- END_OF_FILE
- if test 13368 -ne `wc -c <'startsnap.rexx'`; then
- echo shar: \"'startsnap.rexx'\" unpacked with wrong size!
- fi
- # end of 'startsnap.rexx'
- fi
- echo shar: End of archive 2 \(of 4\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
- Mail comments to the moderator at <amiga-request@cs.odu.edu>.
- Post requests for sources, and general dicussion to comp.sys.amiga.
-